package com.yxhl.zoume.core.officialcar.presenter;

import android.content.Context;

import com.yxhl.zoume.common.presenter.BasePresenter;
import com.yxhl.zoume.common.ui.view.BaseView;
import com.yxhl.zoume.core.officialcar.model.OfficialCarRentTimePicker;
import com.yxhl.zoume.core.func.timepicker.ZMTimePicker;
import com.yxhl.zoume.core.func.timepicker.ZMTimePickerFactory;
import com.yxhl.zoume.core.func.timepicker.view.ZMTimePickerView;

import java.util.ArrayList;

import javax.inject.Inject;

/**
 * Created by sugarya on 16/8/13.
 */
public class RentHourlyTimePickerPresenter extends BasePresenter {


    private static final String TAG = "ZMTimePickerPresenter";

    private ZMTimePickerView mZMTimePickerView;

    private OfficialCarRentTimePicker mZMTimePicker;

    @Inject
    public RentHourlyTimePickerPresenter(Context context) {
        super(context);
    }


    /**
     * 设置 选项1 数据
     *
     * @param optional1List
     */
    public void setOptions1List(ArrayList<String> optional1List) {
        mZMTimePicker = ZMTimePickerFactory.createZMTimePicker(OfficialCarRentTimePicker.class);
        if (optional1List != null && optional1List.size() >= 0) {
            mZMTimePicker.setOptions1List(optional1List);
        }
    }


    public <T extends ZMTimePicker> void showRentHourlyTimePicker(Class<T> clazz) {
        if (mZMTimePicker != null) {
            mZMTimePicker
                    .getZMTimePicker(mContext, false, false, false)
                    .showTimePicker()
                    .setOnOptionsSelectListener(clazz.getSimpleName(), mZMTimePickerView);
        }
    }


    @Override
    public void attachView(BaseView view) {
        if (view instanceof ZMTimePickerView) {
            mZMTimePickerView = (ZMTimePickerView) view;
        }
    }
}
